package com.situ.fly.dao;

import java.util.Map;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

import com.situ.fly.entity.Question;

@Mapper
public interface QuestionDao {

	/**
	 * 
	 *  插入问题
	 * 
	 * 
	 */
	@Insert("insert into question(title,content,type,kiss,uid)"
			+"values(#{title},#{content},#{type},#{kiss},#{uid})")
	//在插入数据库时，获取到数据库自动生成的主键
	@Options(useGeneratedKeys  = true,//使用生成的主键
	keyProperty = "id"//主键放在实体类的id属性中
	)
	int insert(Question question);
	@Select("select question.*, user.nickname from question, user " + 
			"where question.uid = `user`.id and question.id=#{id}")

	Map<String,Object> selectById(Integer id);
}
